
const Dept = require('../models/Dept.js');
const Emp = require('../models/Emp.js');

Dept.hasMany( Emp , {
    foreignKey: 'dept_id',
    onDelete: 'SET NULL',
    onUpdate: 'CASCADE'
});

Emp.belongsTo( Dept , {
    foreignKey: 'dept_id'
});

Dept.destroy({
    where: {
        id: 4
    }
}).then( count => {
    console.log( 'count: ' , count );
}).catch( reason => {
    console.log( 'reason: ' , reason );
});